package project21;

public class Main {

    public static void main(String[] args) {

        Student xiaoxin = new Student();
        xiaoxin.feedPet(new Dog("小汪"));
        xiaoxin.feedPet(new Cat("小白"));
    }

}
class Student{
    public void feedPet( IPet pet){
        pet.beFriendly();
        pet.beAccompanied();
    }
}
//定义接口
interface IPet{
        void beFriendly();
        void beAccompanied();
        }
//定义抽象类
        abstract class Animal{
    private String name;
//定义抽象方法
    public abstract void move();


    public Animal(String name) {
        super();
        this.name = name;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
//继承animal 实现IPet
class Cat extends Animal implements IPet{
public Cat(String name) {
    super(name);
        }
//实现beFriendly方法

    @Override
    public void beFriendly() {
        System.out.println("i am "+ this.getName() +" cat, i am friendly");
    }

    @Override
    public void beAccompanied() {
        System.out.println("i am "+this.getName()+" cat,  i can accompany you quiently ");
    }

//实现be beAccompanied方法


@Override
public void move() {
        // TODO Auto-generated method stub
        System.out.println("cat move quiently");
        }
        }

//继承animal 实现IPet
class Dog extends Animal implements IPet{
public Dog(String name){
        super(name);
        }
//实现beFriendly方法

    @Override
    public void beFriendly() {
        System.out.println("i am "+ this.getName() +" dog, i am friendly");
    }

    @Override
    public void beAccompanied() {
        System.out.println("i am "+this.getName()+" dog, i can talk a walk with you");
    }

@Override
public void move() {
        // TODO Auto-generated method stub
        System.out.println("dog move quickly");
        }
        }